home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / board / IGNUChess151.lha / GNUChess-1.51 / ModeID.c < prev    next >
C/C++ Source or Header  |  1994-02-10  |  909b  |  35 lines

  1. /************************************************************************/
  2. /*                                                                        */
  3. /* ULONG ModeID( char * )                                                */
  4. /*                                                                        */
  5. /* Returns the display mode identifier of a    given monitor:mode name.    */
  6. /* E.g. ModeID( "NTSC:HighRes Lace" ) resolves to 0x00019004.            */
  7. /*                                                                        */
  8. /************************************************************************/
  9.  
  10. #include <graphics/displayinfo.h>
  11.  
  12. #include <proto/graphics.h>
  13.  
  14. #include <string.h>
  15.  
  16. ULONG ModeID( char *name )
  17. {
  18.     ULONG                id    = INVALID_ID;
  19.     DisplayInfoHandle    dih;
  20.     struct NameInfo        ni;
  21.  
  22.     while ( ( id = NextDisplayInfo( id ) ) != INVALID_ID ) {
  23.         if ( ! ModeNotAvailable( id ) ) {
  24.             if ( dih = FindDisplayInfo( id ) ) {
  25.                 if ( GetDisplayInfoData( dih, (UBYTE *) &ni, sizeof( struct NameInfo ), DTAG_NAME, 0 ) ) {
  26.                     if ( ! stricmp( name, ni.Name ) ) {
  27.                         break;
  28.                     }
  29.                 }
  30.             }
  31.         }
  32.     }
  33.     return id;
  34. }
  35.